package com.botarena.server.model;

import java.util.Date;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class Battle extends Entity {

	@Persistent
	private Date time;
	@Persistent
	private Key bot1;
	@Persistent
	private Key bot2;
	@Persistent
	private Key winner;
	@Persistent
	private Key process;
	@Persistent
	private Key contest;
	@Persistent
	private String justification;
	
	public Date getTime() {
		return time;
	}
	
	public void setTime(Date time) {
		this.time = time;
	}
	
	public Key getBot1() {
		return bot1;
	}
	
	public void setBot1(Key bot1) {
		this.bot1 = bot1;
	}
	
	public Key getBot2() {
		return bot2;
	}
	
	public void setBot2(Key bot2) {
		this.bot2 = bot2;
	}
	
	public Key getWinner() {
		return winner;
	}
	
	public int getWinnerNum() {
		if (winner == null)
			return 0;
		if (winner.equals(bot1))
			return 1;
		else
			return 2;
	}
	
	public void setWinner(Key winner) {
		this.winner = winner;
	}
	
	public Key getProcess() {
		return process;
	}
	
	public void setProcess(Key process) {
		this.process = process;
	}
	
	public Key getContest() {
		return contest;
	}
	
	public void setContest(Key contest) {
		this.contest = contest;
	}

	public void setJustification(String justification) {
		this.justification = justification;
	}
	
	public String getJustification() {
		return justification;
	}

}
